﻿#ifndef SH_ONLY_HRADER
#include "streambuffer.hpp"
#endif


namespace sh {

SH_ONLY_HRADER_INLINE 
StreamBuffer::StreamBuffer() noexcept
	: Buffer()
{
}

SH_ONLY_HRADER_INLINE
StreamBuffer::StreamBuffer(ByteOrder order)
	: StreamBuffer()
{
	convert_.setDefaultEndian(order);
}

SH_ONLY_HRADER_INLINE
StreamBuffer::StreamBuffer(Buffer const& rhs)
	: Buffer(rhs)
{

}

SH_ONLY_HRADER_INLINE
StreamBuffer::StreamBuffer(Buffer&& rhs) noexcept
	: Buffer(std::forward<Buffer>(rhs))
{

}

SH_ONLY_HRADER_INLINE
StreamBuffer::StreamBuffer(StreamBuffer const& rhs)
{
	buffer_  = rhs.buffer_;
	convert_ = rhs.convert_;
}

SH_ONLY_HRADER_INLINE
StreamBuffer::StreamBuffer(StreamBuffer&& rhs) noexcept
{
	buffer_.swap(rhs.buffer_);
	convert_ = rhs.convert_;
}

SH_ONLY_HRADER_INLINE
StreamBuffer& StreamBuffer::operator=(Buffer const& rhs)
{
	buffer_ = rhs;
	return *this;
}

SH_ONLY_HRADER_INLINE
StreamBuffer& StreamBuffer::operator=(Buffer&& rhs) noexcept
{
	Buffer::swap(rhs);
	return *this;
}

SH_ONLY_HRADER_INLINE
StreamBuffer& StreamBuffer::operator=(StreamBuffer const& rhs)
{
	buffer_  = rhs.buffer_;
	convert_ = rhs.convert_;
	return *this;
}

SH_ONLY_HRADER_INLINE
StreamBuffer& StreamBuffer::operator=(StreamBuffer&& rhs) noexcept
{
	buffer_.swap(rhs.buffer_);
	convert_ = rhs.convert_;
	return *this;
}

SH_ONLY_HRADER_INLINE
StreamBuffer& StreamBuffer::operator=(std::initializer_list<value_type> list)
{
	buffer_ = list;
	return *this;
}

SH_ONLY_HRADER_INLINE
StreamBuffer::~StreamBuffer()
{
}

SH_ONLY_HRADER_INLINE
void StreamBuffer::swap(StreamBuffer& rhs)
{
	Buffer::swap(rhs);
	std::swap(convert_, rhs.convert_);
}

SH_ONLY_HRADER_INLINE
void StreamBuffer::setByteOrder(sh::ByteOrder order)
{
	convert_.setDefaultEndian(order);
}

SH_ONLY_HRADER_INLINE
sh::ByteOrder StreamBuffer::byteOrder() const
{
	return convert_.getDefaultEndian();
}


} // namespace sh
